﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using ET.DBCommon.Model;
using MySql.Data.MySqlClient;

namespace ET.DBCommon.DAL
{
   public  class PassenergerPointDAL
    {
        public static void UpDatePassenger(int id,String name,int num,float score)
        {
            String sql = "Insert into passenergerpoint (ExamresultID,PlatformName,PassengerNum,DeleteScore) values ("+ id + ",'"+ name + "','"+ num + "','"+ score + "');";
            DbHelper.ExecuteDataset(sql);
        }

        public static int SelectPoint(int id)
        {
            String sql = "SELECT TotalScoreDescribe FROM examresults where ID=" + id;
            DataSet ds = DbHelper.ExecuteDataset(sql);
            String total = "";
            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                DataTable dt = ds.Tables[0];
                
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    String str=(dt.Rows[0][0]).ToString().Split('客')[1];
                    string pattern = @"\d+";

                    MatchCollection matches = Regex.Matches(str, pattern);

                    foreach (Match match in matches)
                    {
                        total= total+match.Value;
                    }
                  
                }
                return Convert.ToInt16(total);
            }
            else
            {
                return 0;
            }
            
        }
    }
}
